<!-- 充值 -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="${baes }/static/hui/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="${baes }/static/hui/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="${baes }/static/hui/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="${baes }/static/hui/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="${baes }/static/hui/static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>充值中心</title>
<link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="page-container">
	<form class="form form-horizontal" id="form-article-add" method="post">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">姓名:</label>
			<div class="formControls col-xs-8 col-sm-9">
				${businessUser.nickname }
				<input type="hidden" name="businessId" value="${businessUser.id}">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">账号</label>
			<div class="formControls col-xs-5 col-sm-3">
				<input type="text" class="input-text newmer" value="" placeholder="请输入充值的账号" id="" name="phone">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">金额<b style="color: red;font-size: 16px;">*</b>:</label>
			<div class="formControls col-xs-5 col-sm-3">
				<input type="text" class="input-text newmer" value="" oninput="changeY()" placeholder="请输入充值金额" id="" name="totalAssets">
			</div>
			<label class="form-label col-xs-4 col-sm-2" style="text-align: left;" id="showRMB"></label>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button id="submitButton" class="btn btn-primary radius" type="button" > 充值</button>
				<button style="margin-right: 30px; background: #999; color: #fff; border-color: #999;display:none;" disabled="disabled" id="submitShow" class="btn btn-primary radius" type="button" > 充值中。。</button>
				<button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
			</div>
		</div>
	</form>
</div>
 

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="${baes }/static/hui/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="${baes }/static/hui/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="${baes }/static/hui/static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="${baes }/static/hui/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="${baes }/static/hui/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="${baes }/static/hui/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="${baes }/static/hui/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript" src="${baes }/static/hui/lib/webuploader/0.1.5/webuploader.min.js"></script> 
<script type="text/javascript">
	function submit1(){
		var businessPhone = '${businessUser.phone}';
		
		//对比输入的账号是否相同，不相同就退出
		
		//否则就提交 
	}
</script>
<script type="text/javascript">
function smalltoBIG(n)     
{    
    var fraction = ['角', '分'];    
    var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];    
    var unit = [ ['元', '万', '亿'], ['', '拾', '佰', '仟']  ];    
    var head = n < 0? '欠': '';    
    n = Math.abs(n);    
  
    var s = '';    
  
    for (var i = 0; i < fraction.length; i++)     
    {    
        s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');    
    }    
    s = s || '整';    
    n = Math.floor(n);    
  
    for (var i = 0; i < unit[0].length && n > 0; i++)     
    {    
        var p = '';    
        for (var j = 0; j < unit[1].length && n > 0; j++)     
        {    
            p = digit[n % 10] + unit[1][j] + p;    
            n = Math.floor(n / 10);    
        }    
        s = p.replace(/(零.)*零$/, '').replace(/^$/, '零')  + unit[0][i] + s;    
    }    
    return head + s.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零').replace(/^整$/, '零元整');    
}
function changeY(){
	
	var totalAssets = $("input[name=totalAssets]").val();
	
	
	
	var data = smalltoBIG(totalAssets);
	$("#showRMB").text(data);
	$("#showRMB").show();
}
$(document).ready(function(){
	$("#submitButton").click(function(){
		var phone = $("input[name=phone]").val();
		var totalAssets = $("input[name=totalAssets]").val();
		var businessId = $("input[name=businessId]").val();
		var isCheck = true;
		if(phone==''){
			layer.msg("请输入账号");
			isCheck = false;
			return false;
		}
		if(totalAssets==''){
			layer.msg("请输入金额");
			isCheck = false;
			return false;
		}
		if(!$.isNumeric(totalAssets)){
			layer.msg('金额格式错误');
			isCheck = false;
			return false;
		}
		if(isCheck==true){
			layer.confirm('确定要给该账号充值吗?', {icon: 3, title:'提示'}, function(index){
				layer.close(index);
				$("#submitButton").hide();
				$("#submitShow").show();
				$.ajax({
		        	url:"${base}/admin/sumRecharger",
		            type:'post',
		            dataType:'json',
		            data:{"businessId":businessId,"totalAssets":totalAssets,"phone":phone},
		            success:function(res)
		            {
		                if(res.code==1){
		                	layer.alert('充值成功', {icon: 1});
		                }else if(res.code==0){
		                	layer.alert('充值失败', {icon: 1});
		                }
		                $("#submitButton").show();
						$("#submitShow").hide();
		            }
		        });
		        return false;
			});
		}
	});
});
</script>
</body>
</html>